package cate.game.play.skill.passive.guild;

import cate.common.table.d.GDSkill;
import cate.game.play.base.HpCfg;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时使目标受到基于自身当前生命值8%的伤害，60%概率附加【天魔解体】(受到的物理伤害提升7%，受疗效果降低15%，持续2回合)，每回合至多生效2个目标
 */
public class 天魔解体PH extends PassiveHandler {


	private HpCfg 血量配置;

	private int buff概率;

	private int buff;

	private int 人数;

	//血量配置=？？&buff概率=6000&buff=？？&人数=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量配置 = new HpCfg(args);
		buff概率 = args.getInt("buff概率", 0);
		buff = args.getInt("buff", 0);
		人数 = args.getInt("人数", 0);
	}

	private int num;

	@Override
	public void onRoundBegin(ActionCtx action) {
		num = 0;
	}

	@Override
	public void beforeSkillSettleAsActor(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (num >= 人数) {
			return;
		}
		if (!action.getSkill().cfg.isEffectType(GDSkill.EffectType.伤害)) {
			return;
		}
		num++;
		effect.getTargetCtx(target.getPid()).addHpCfg(血量配置);
		target.buff.tryAddByTid(action, skill.owner, buff, buff概率);
	}
}
